import requests

url =" http://127.0.0.1:8000/admin/"
#默认可以重定向，返回的是重定向后的登录页面
response = requests.get(url , allow_redirects=False)
print(response.headers.get("Location"))
print(response.status_code)
print(response.text)
#将重定向后的地址拼接成新的url
location = response.headers.get("Location")
location = f" http://127.0.0.1:8000/admin/{location}"
res = requests.get(location)
print(res.status_code)